package demo2;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 苏李涛
 * Date: 2024-05-18
 * Time: 21:51
 */
public class Test {
    //只要你实现了接口，并且有对应的方法，就可以（通过向上转型），然后new这个类直接调用
    public static void main3(String[] args) {
        fly(new Airplany());

    }


    public static void run(IRunning iRunning) {
        iRunning.run();
    }

    public static void swim(ISwimming swimming) {
        swimming.swim();
    }

    public static void fly(IFly iFly) {
        iFly.fly();
    }

    //用接口来直接调用实现
    public static void main(String[] args) {
        run(new Dog("旺财", 2));
        swim(new Fish("小鱼儿", 4));
        fly(new Duck("鸭子", 3));

    }

    /*public static void func1(Animal animal) {
        animal.eat();
    }*/

    public static void main1(String[] args) {
        /*func1(new Dog("旺财", 2));
        func1(new Duck("鸭子", 3));
        func1(new Fish("小鱼儿", 4));*/
    }


    public static void main5(String[] args) {
        Dog dog1 = new Dog("旺财", 3);
        Dog dog2 = new Dog("旺财", 2);

        System.out.println(dog1.equals(dog2));

        /*int[] arr = new int[2];
        int[] arr1 = new int[2];
        Object obj1 = new Object();
        System.out.println(arr.equals(arr1));*/
    }

}
